package com.kot.backend.service.impl.pk;

import com.kot.backend.consumer.WebSocketServer;
import com.kot.backend.consumer.utils.BotStep;
import com.kot.backend.service.pk.ReceiveBotMoveService;
import org.springframework.stereotype.Service;

@Service
public class ReceiveBotMoveServiceImpl implements ReceiveBotMoveService {
    @Override
    public String receiveBotMove(Integer userId, Integer direction) {
//        System.out.println("receive bot move: " + userId + " " + direction + " ");
        if (WebSocketServer.users.get(userId) != null) {//判断玩家有没有中断连接导致该id不存在后端了
            BotStep botStep = WebSocketServer.BOTS.get(userId);
            if(botStep!=null){
                botStep.setD(direction);
            }

        }

        return "receive bot move success";
    }
}
